<!DOCTYPE html>
<html>
<head>
    <title>MELSEC iQ-F FX5用户手册 (应用篇)</title>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <link rel="stylesheet" href="node_modules/@ztree/ztree_v3/css/zTreeStyle/zTreeStyle.css" type="text/css">
    <style type="text/css">
        #nav {
            float: left;
            width: 20%;
        }
        #content {
            float: right;
            width: 80%;
        }
        #contentContainer {
            width: 100%;
            height: 100%;
            border: 0;
            margin: 0;
            padding: 0;
        }
    </style>
</head>
<body>
<div id="nav">
    <ul id="toc" class="ztree"></ul>
</div>
<div id="content">
    <iframe src="docs/text/cover.html" id="contentContainer"></iframe>
</div>

<script type="text/javascript" src="node_modules/@ztree/ztree_v3/js/jquery-1.4.4.min.js"></script>
<script type="text/javascript" src="node_modules/@ztree/ztree_v3/js/jquery.ztree.core.js"></script>
<script LANGUAGE="JavaScript">
    var zTreeObj;
    var setting = {
        data: {
            key: {
                name: 'TOC_TEXT',
                // url: 'TOC_MURL',
            },
            simpleData: {
                enable: true,
                idKey: 'TOC_ID',
                pIdKey: 'TOC_PID',
                rootPid: 1,
            }
        },
        async: {
            enable: true,
            url: 'toc.json',
            type: "get",
            contentType: "application/json",
        },
        callback: {
            onClick: function (event, treeId, treeNode, clickFlag) {
                console.log(treeNode.TOC_MURL);
                $('#contentContainer').attr("src", treeNode.TOC_MURL);
            },
            onAsyncSuccess: function (event, treeId, treeNode, msg){

                var treeObj = $.fn.zTree.getZTreeObj(treeId);

                var nodes = treeObj.getNodes();

                if (nodes.length>0) {

                    for(var i=0;i<nodes.length;i++){

                        treeObj.expandNode(nodes[i], true, false, false);//默认展开第一级节点

                    }

                }
                

            }
        }
    };
    var zNodes = [];
    $(window).resize(function(){
        $('#contentContainer').css('height', $(window).height());
    });
    $(document).ready(function () {
        $.fn.zTree.init($("#toc"), setting, zNodes);
        $(window).resize();
    });
</script>
</body>
</html>